package com.devmindset.legoframework.usage.client.component;

import com.devmindset.legoframework.client.mvc.LegoComponent;
import com.devmindset.legoframework.client.mvc.LegoModel;
import com.devmindset.legoframework.client.mvc.metadata.ComponentStory;
import com.devmindset.legoframework.client.mvc.metadata.Stories;
import com.devmindset.legoframework.usage.client.constants.UsageConstants;
import com.devmindset.legoframework.usage.client.event.Events;
import com.devmindset.legoframework.usage.client.text.UsageTexts;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;

public class OverviewComponent extends LegoComponent {

	/** {@inheritDoc} */	
	@Override
	public Canvas construct(LegoModel model) {
		HLayout root = new HLayout();
		root.setMembersMargin(5);
		VLayout paddingWrapper = new VLayout();
		paddingWrapper.setWidth("50%");
		paddingWrapper.setHeight100();
		paddingWrapper.setPadding(15);
		HTMLFlow text = new HTMLFlow(UsageTexts.get().overviewHTML());
		text.setStyleName("overview");
		text.setBackgroundColor("#EDEDED");
		text.setBorder(UsageConstants.COMPONENT_BORDER);
		text.setPadding(10);
		text.setWidth100();
		text.setHeight100();
		paddingWrapper.addMember(text);
		HTMLFlow html = new HTMLFlow("<center><img src=\"images/overview.jpg\" width=\"440px\" height=\"525px\"/></center>");
		html.setWidth("50%");
		html.setHeight100();
		root.addMember(paddingWrapper);
		root.addMember(html);
		return root;
	}
	
	/** {@inheritDoc} */	
	@Override
	public void calculate(LegoModel model) {
		//one-time construction component; nothing to (re)calculate.
	}

	/** {@inheritDoc} */	
	public ComponentStory myStory() {
		return Stories.component()
			.constructedBy(Events.RENDER_OVERVIEW_COMPONENT)
			.knownAs("Overview Component");
	}

}